﻿//using HPSocket;
using System.Net.Sockets;
using System.Net;
using System.Text;
using HPSocket;

namespace SocketConsoleApp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Server server = new Server(1000, 1024);
            //server.Init();
            //server.Start(new IPEndPoint(IPAddress.Any, 20000));

            HPTcpServer server = new HPTcpServer(null, 20000, 4, 100);
            server.AsyncEventArgsCallback = (args) =>
            {
                var data = args.MemoryBuffer.Slice(args.Offset, args.BytesTransferred);
                Console.WriteLine($"{args.AcceptSocket?.RemoteEndPoint}:{Encoding.ASCII.GetString(data.Span)}");
            };

            server.AsyncReceivedDataCallback = (data) =>
            {
                var span = data.Buffer.AsSpan();
                Console.WriteLine($"{data.Client?.RemoteEndPoint}:{Encoding.ASCII.GetString(span.Slice(data.Offset, data.Length))}");
            };
            server.BeginListen();

            Console.ReadLine();
            Console.ReadLine();


        }
    }

}